/* 平铺的数组转树形结构 */
export const transitionToTreeData: any = (list: any[], pid: number = 0) => list.filter((item: any) => item.pid === pid).map((item: any) => {
    return {...item, children: transitionToTreeData(list, item.id)}
})

/* 平铺的数组转树形结构 */
export const transToTreeData = (list: any, rootValue: any) => {
    const array: any[] = []
    list.forEach((item: any) => {
        if (item.pid === rootValue) {
            const children = transToTreeData(list, item.id)
            if (children.length) {
                item.children = children
            }
            array.push(item)
        }
    })
    return array
}
